Add values(start, end) slice accessor to DoubleEndedQueue#6522
Add values(start, end) slice accessor to DoubleEndedQueue#6522ernestognw wants to merge 2 commits into
values(start, end) slice accessor to DoubleEndedQueue#6522Conversation
Mirrors the paginated `values` accessor in `EnumerableSet`. Clamps `end` to `length(deque)` and `start` to `end` (both with `Math.min`), then reads the slice through the wraparound-aware `_begin` offset. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 508c781 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR adds a new 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
values(Bytes32Deque storage deque, uint256 start, uint256 end)toDoubleEndedQueue, mirroring the paginatedvaluesaccessor inEnumerableSet.endis clamped tolength(deque)andstartis clamped to the (clamped)endviaMath.min, so any out-of-range inputs return a properly bounded slice instead of reverting.deque._data[_begin + i], so it honors the wraparound indices used bypushFront/popFront.Test plan
npx hardhat test test/utils/structs/DoubleEndedQueue.test.js— 22 cases passing (16 pre-existing + 6 new undervalues: empty deque, full-range, exhaustive[0..4] x [0..4]pagination,MaxUint256end clamping,start > end/start > lengthclamping, and a wraparound case that exercises the_begin - 1underflow path viapushFront).